package cn.seqdata.jpa.lookup;

import java.util.Objects;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import cn.seqdata.jpa.JpaAuditableObject;

public class LookupJpaObject extends LookupKeyval<Long> {

	public LookupJpaObject() {
	}

	public LookupJpaObject(Long id, String name) {
		super(id, name);
	}

	public LookupJpaObject(JpaAuditableObject entity) {
		super(entity.getId(), entity.getName());
		setOrderNo(entity.getOrderNo());
	}

	@Override
	@JsonSerialize(using = cn.seqdata.jackson.LongSerializer.class)
	public Long getId() {
		return id;
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(id);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LookupJpaObject other = (LookupJpaObject) obj;
		return Objects.equals(id, other.id);
	}
}
